package com.chap9;
import java.awt.*;
import javax.swing.*;
public class WinPanel extends JFrame{
    //容器，组件变量
    public JTextField jtfname,jtfwork,jtfhome;
    public JLabel jlname,jlwork,jlhome,jok;
    public JButton jb;
    public JPanel jpname,jpwork,jphome;
    JTextArea jta;
    JScrollPane jsp;
    JSplitPane jsplit;
    public static void main(String[] args) {
        WinPanel winpanel=new WinPanel();
    }
    public WinPanel(){
        //标签
        jlname=new JLabel("name:");
        jlwork=new JLabel("work:");
        jlhome=new JLabel("home:");
        //文本区
        jtfname=new JTextField(10);
        jtfwork=new JTextField(10);
        jtfhome=new JTextField(10);
        //按钮
        jb=new JButton("OK");
        //面板
        jpname=new JPanel();
        jpwork=new JPanel();
        jphome=new JPanel();
        //窗体布局
        this.setLayout(new GridLayout(5,1));
        this.add(jpname);
        this.add(jpwork);
        this.add(jphome);

        jpname.add(jlname);jpname.add(jtfname);
        jpwork.add(jlwork);jpwork.add(jtfwork);
        jphome.add(jlhome);jphome.add(jtfhome);

        jta=new JTextArea(10,10);
        jsp=new JScrollPane(jta);

        jok=new JLabel("I am ok");
        jsplit=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,false,jsp,jok);

        this.add(jb);
        this.add(jsplit);

        this.setBounds(300,500,300,300);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
